var app = new Vue({
	el: '#app',
	mixins:[page,isLogin],
	components: {
		headers: header,
		navs:nav,
		footers:footer,
		login:login
	},
	data: {
		bgImg:'img/PCindex/top1.jpg',
		navState:'行业动态',
		newList: '', //最新动态
		currentClass:'',//当前分类
		recent_news: '', //最新动态
		policyInfoList: '', //政策资讯列表
		weekHotList:'',//本周热点
		topLine:'',//头条信息
	},
	methods: {
		//header组件的搜索方法
		searchHeader: function(searchCtx) {
			xq.toast1(searchCtx)
		},
		//显示和隐藏右侧边栏
		showNewsList: function(event) {
			$(event.target).parents('.newsList').find('.showNewsList').toggle(300);
		},
		//获取政策资讯
		getPolicyInfoList: function() {
			var _this = this;
			var method = 'News/GetNewList';
			var param = {
				id: '',
				ColumnID: '',
				ListCount: '3', //获取数量
				PageIndex: '',
				IsShowPhoto: false
			};
			xq.getUrl(method, param, function(res) {
				if(res.data) {
					_this.policyInfoList = res.data;
				}
			})
		},
		//获取最新动态
		getData: function() {
			var _this = this;
			var method = 'News/GetNewsTitle';
			var param = {
				id: '',
				ColumnID: '',
				ListCount: '4', //获取数量
				PageIndex: '',
				IsShowPhoto: false
			};
			xq.getUrl(method, param, function(res) {
				if(res.data) {
					_this.recent_news = res.data;
				}
			})
		},
		//获取本周热点
		getWeekHot:function(){
			var _this = this;
			var method = 'News/GetWeekHot';
			var param = {
				id: '',
				ColumnID: '',
				ListCount: '4', //获取数量
				PageIndex: '',
				IsShowPhoto: false
			};
			xq.getUrl(method, param, function(res) {
				if(res.data) {
					_this.weekHotList = res.data;
				}
			})
		},
		//获取头条
		getTopLine: function() {
			var _this = this;
			var method = 'News/GetTopLine';
			var param = {
				id: '',
				ColumnID: '',
				ListCount: '1', //获取数量
				PageIndex: '',
				IsShowPhoto: false
			};
			xq.getUrl(method, param, function(res) {
				if(res.data) {
					_this.topLine = res.data;
				}
			})
		},
		//获取数据列表
		getNewsList: function(currentPage) {
			var _this = this;
			if(currentPage){
				currentPage = currentPage
			}else{
				currentPage = 1;
			}
			var method = 'News/GetNewListByPage';
			var param = {
				id: '',
				ColumnID: _this.currentClass,
				ListCount: _this.onePageCount, //获取数量
				PageIndex: currentPage,
				IsShowPhoto: true
			};
			xq.getUrl(method, param, function(res) {
				if(res.data) {
					if(!_this.totalPage){
						_this.totalPage = Math.ceil(res.data.TotalCount/_this.onePageCount);
						_this.initPage();
					}
					_this.newList = res.data.ListEntity;
				}
			})
		},
		//跳转新闻详情文章
		toDetailMsg: function(id) {
			var Url = 'newsDetail.html?id='+id;
			window.open(Url,'_blank');
		},
		//跳转新闻列表页
		toArticleList: function(id) {
			var Url = 'newsList.html?id='+id;
			window.open(Url,'_self');
		},
		
		
	},
	mounted: function() {
		this.currentClass = xq.getQueryString('id');
		this.getData();
		this.getNewsList();
		this.getWeekHot();
		this.getPolicyInfoList();
		this.getTopLine();
	},
	updated: function() {

	}
})